﻿#pragma once
#include "Unordered_HashTable.h"
template <class K, class V, class Con = Conversion<K>>
class unordered_map
{
	struct key
	{
		const K& operator()(const pair<K, V>& kv)
		{
			return kv.first;
		}
	};
public:
	typedef typename Hash_bucket::HashTable<K, pair<const K, V>, key, Con>::Iterator iterator;

	iterator begin()
	{
		return _hashmap.begin();
	}

	iterator end()
	{
		return _hashmap.end();
	}

	bool insert(const pair<K, V>& kv)
	{
		return _hashmap.Insert(kv);
	}
private:
	Hash_bucket::HashTable<K, pair<const K, V>, key, Con> _hashmap;
};

void test_map1()
{
	unordered_map<string, string> dict;
	dict.insert(make_pair("sort", ""));
	dict.insert(make_pair("left", ""));
	dict.insert(make_pair("right", "L"));
	dict.insert(make_pair("string", ""));

	for (auto& kv : dict)
	{
		//kv.first += 'x';
		//kv.second += 'y';

		cout << kv.first << ":" << kv.second << endl;
	}
	cout << endl;

	unordered_map<string, string>::iterator it = dict.begin();
	while (it != dict.end())
	{
		cout << it->first << ": " << it->second << endl; 
		it++;
	}
}